Errors When Using Twilio Sub-Account

I change the configuration from using my main Twilio account SID and authentication tokens to a newly created Twilio sub-account SID and authentication token. I get these errors in the log. The phone number I'm using is valid, it works when I use the main account credentials.

This sounds similar to something that was fixed in an earlier version.

## Data Model

2288: Twilio: Connections to multiple sub accounts causes all but one to have an authentication error
Fixed a regression which caused account credentials of the last loaded Twilio account to be used for all Twilio accounts. Multiple Twilio accounts can now be used without authentication errors
https://forum.inductiveautomation.com/t/nightly-8-1-changelogs-2021/42410/85

BTW, I'm running version 8.1.18.

First Error

com.twilio.exception.ApiException: The From phone number +XXX is not a valid, SMS-capable inbound phone number or short code for your account.
at com.twilio.rest.api.v2010.account.MessageCreator.create(MessageCreator.java:505)
at com.digitalpetri.ignition.twilio.accounts.TwilioAccount$ConnectedTwilioAccount.lambda$sendSms$6(TwilioAccount.java:346)
at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.base/java.lang.Thread.run(Unknown Source)

Second Error

java.util.concurrent.ExecutionException: com.digitalpetri.ignition.twilio.accounts.TwilioAccount$TwilioAccountException: The From phone number +XXX is not a valid, SMS-capable inbound phone number or short code for your account.
at java.base/java.util.concurrent.FutureTask.report(Unknown Source)
at java.base/java.util.concurrent.FutureTask.get(Unknown Source)
at com.digitalpetri.ignition.twilio.accounts.TwilioAccount$ConnectedTwilioAccount.sendSms(TwilioAccount.java:358)
at com.digitalpetri.ignition.twilio.alarming.TwilioNotificationProfile.lambda$sendNotification$2(TwilioNotificationProfile.java:125)
at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(Unknown Source)
at java.base/java.util.stream.ReferencePipeline$2$1.accept(Unknown Source)
at java.base/java.util.Spliterators$ArraySpliterator.forEachRemaining(Unknown Source)
at java.base/java.util.stream.AbstractPipeline.copyInto(Unknown Source)
at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(Unknown Source)
at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(Unknown Source)
at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(Unknown Source)
at java.base/java.util.stream.AbstractPipeline.evaluate(Unknown Source)
at java.base/java.util.stream.ReferencePipeline.forEach(Unknown Source)
at com.digitalpetri.ignition.twilio.alarming.TwilioNotificationProfile.sendNotification(TwilioNotificationProfile.java:120)
at com.inductiveautomation.ignition.alarming.pipelines.blocks.NotificationBlock$NotificationContextImpl.run(NotificationBlock.java:521)
at com.inductiveautomation.ignition.common.execution.impl.BasicExecutionEngine$ThrowableCatchingRunnable.run(BasicExecutionEngine.java:539)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.base/java.lang.Thread.run(Unknown Source)
Caused by: com.digitalpetri.ignition.twilio.accounts.TwilioAccount$TwilioAccountException: The From phone number +XXX is not a valid, SMS-capable inbound phone number or short code for your account.
at com.digitalpetri.ignition.twilio.accounts.TwilioAccount$ConnectedTwilioAccount.lambda$sendSms$6(TwilioAccount.java:354)
... 5 common frames omitted

Thank you.

In an abundance of caution I wiped your actual number from the stacktraces.

I'm not really sure what to say about the error beyond that. It's coming from Twilio directly, apparently:

You missed one. Top of the second stack trace.

Are you also able to clear the edit history, because we can still go in and see what it was before your edit(s)

1 Like

AFAIK you need to either move this number to the sub account or provision a new number for the sub account.

Sub accounts exist to act as "containers" that separate resources. You can't share resources between them, and I don't think you can share resources between parent/sub either, but I'm not 100% sure.

Thank you for scrubbing my stack traces...I'll remember that for the future.
Twilio can be tricky. AFAIK when you use the API you have to send the main account SID & auth token as well as the sub-account SID & auth token. I'm not entirely sure. I sent their tech support a trouble ticket. We I figure it out I'll post the solution. Thanks for the help!

Solved.

Sub-accounts need their own phone number when using the Ignition Twilio module. Twilio documentation is not vary concise, it leads you to believe a sub-account can us the main accounts phone number...but only if you transfer to the number from main to sub when using their API which isn't the use case when using Ignition and the Twilio module.

Thanks for the input everyone!

Regards,
Ted.