Merge pull request #1142 from automatisch/fix-twilio-receive-sms-test-run
fix(twilio/receive-sms): use phone number via phone number sid
This commit is contained in:
@@ -0,0 +1,14 @@
|
|||||||
|
import { IGlobalVariable } from "@automatisch/types";
|
||||||
|
|
||||||
|
type Response = {
|
||||||
|
sid: string;
|
||||||
|
phone_number: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export default async function getIncomingPhoneNumber($: IGlobalVariable) {
|
||||||
|
const phoneNumberSid = $.step.parameters.phoneNumberSid as string;
|
||||||
|
const path = `/2010-04-01/Accounts/${$.auth.data.accountSid}/IncomingPhoneNumbers/${phoneNumberSid}.json`;
|
||||||
|
const response = await $.http.get<Response>(path);
|
||||||
|
|
||||||
|
return response.data;
|
||||||
|
};
|
@@ -1,10 +1,11 @@
|
|||||||
import { IGlobalVariable, IJSONObject } from '@automatisch/types';
|
import { IGlobalVariable, IJSONObject } from '@automatisch/types';
|
||||||
|
import getIncomingPhoneNumber from '../../common/get-incoming-phone-number';
|
||||||
|
|
||||||
const fetchMessages = async ($: IGlobalVariable) => {
|
const fetchMessages = async ($: IGlobalVariable) => {
|
||||||
const toNumber = $.step.parameters.toNumber as string;
|
const incomingPhoneNumber = await getIncomingPhoneNumber($);
|
||||||
|
|
||||||
let response;
|
let response;
|
||||||
let requestPath = `/2010-04-01/Accounts/${$.auth.data.accountSid}/Messages.json?To=${toNumber}`;
|
let requestPath = `/2010-04-01/Accounts/${$.auth.data.accountSid}/Messages.json?To=${incomingPhoneNumber.phone_number}`;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
response = await $.http.get(requestPath);
|
response = await $.http.get(requestPath);
|
||||||
|
Reference in New Issue
Block a user