From Stephen, 3 Years ago, written in JavaScript.
- go back
Embed
Viewing differences between and Untitled
  1. /*
  2. * id contains project id
  3. * phones is an array of objects containing { number: <signalwire provided telephone number e.g. +12125551212>, ... }
  4. * token contains project token
  5. * signalwireSpaceUrl option contains the account space url
  6. * Message object argument contains { body: string, to: <recipient telephone number e.g. +12125551212> }
  7. */
  8.  
  9. import { RestClient as signalWire } from '@signalwire/node';
  10.  
  11. import properties from './properties';
  12.  
  13. const {
  14.         id, phones, signalwireSpaceUrl, token
  15. } = properties;
  16.  
  17. const client = signalWire( id, token, { signalwireSpaceUrl });
  18.  
  19. /** @type {(message: Message) => Promise<Response>} */
  20. const send: = message => client.messages.create({
  21.         from: phones[ 0 ].number, ...message
  22. });
  23.  
  24. export default send;