bootdesk/chat-sdk

TwilioAdapter
in package
implements Adapter, MustRehydrateAttachments, RequiresSyncResponse

Table of Contents

Interfaces

Adapter
MustRehydrateAttachments
RequiresSyncResponse
Marker interface for adapters that require the bot's response within the same HTTP request.

Constants

API_VERSION  : mixed = '2010-04-01'
TWILIO_MESSAGE_LIMIT  : mixed = 1600

Properties

$accountSid  : string
$apiUrl  : string
$authToken  : string
$chat  : Chat|null
$formatConverter  : TwilioFormatConverter
$httpClient  : ClientInterface
$messagingServiceSid  : string|null
$phoneNumber  : string|null
$psrFactory  : Psr17Factory|null
$statusCallbackUrl  : string|null
$webhookUrl  : string|null
$webhookVerifier  : TwilioWebhookVerifier|null

Methods

__construct()  : mixed
addReaction()  : void
channelIdFromThreadId()  : string
createResponse()  : ResponseInterface|null
decodeThreadId()  : mixed
deleteMessage()  : void
disconnect()  : void
editMessage()  : SentMessage
encodeThreadId()  : string
fetchChannelInfo()  : ChannelInfo|null
fetchMedia()  : StreamInterface
fetchMessages()  : FetchResult
fetchThread()  : ThreadInfo
getBotUserId()  : string|null
getFormatConverter()  : FormatConverter|null
getName()  : string
getUser()  : UserInfo|null
initialize()  : void
openDM()  : string|null
parseWebhook()  : Message
postMessage()  : SentMessage
rehydrateAttachment()  : Attachment
removeReaction()  : void
startTyping()  : void
stream()  : SentMessage|null
verifyWebhook()  : ResponseInterface|null
apiCall()  : array<string|int, mixed>
attachmentType()  : string
mediaUrls()  : array<string|int, mixed>
parseDate()  : DateTimeImmutable
parseResource()  : Message
renderPostableText()  : string
senderFields()  : array<string|int, mixed>
threadIdForResource()  : string
compareMessageDates()  : int

Constants

TWILIO_MESSAGE_LIMIT

private mixed TWILIO_MESSAGE_LIMIT = 1600

Properties

$apiUrl read-only

protected string $apiUrl = 'https://api.twilio.com'

$messagingServiceSid read-only

protected string|null $messagingServiceSid = null

$phoneNumber read-only

protected string|null $phoneNumber = null

$psrFactory read-only

protected Psr17Factory|null $psrFactory = null

$statusCallbackUrl read-only

protected string|null $statusCallbackUrl = null

$webhookUrl read-only

protected string|null $webhookUrl = null

Methods

__construct()

public __construct(string $accountSid, string $authToken, ClientInterface $httpClient[, string|null $phoneNumber = null ][, string|null $messagingServiceSid = null ][, string|null $webhookUrl = null ][, string|null $statusCallbackUrl = null ][, Psr17Factory|null $psrFactory = null ][, string $apiUrl = 'https://api.twilio.com' ]) : mixed
Parameters
$accountSid : string
$authToken : string
$httpClient : ClientInterface
$phoneNumber : string|null = null
$messagingServiceSid : string|null = null
$webhookUrl : string|null = null
$statusCallbackUrl : string|null = null
$psrFactory : Psr17Factory|null = null
$apiUrl : string = 'https://api.twilio.com'

addReaction()

public addReaction(string $threadId, string $messageId, string $emoji) : void
Parameters
$threadId : string
$messageId : string
$emoji : string

channelIdFromThreadId()

public channelIdFromThreadId(string $threadId) : string
Parameters
$threadId : string
Return values
string

createResponse()

public createResponse() : ResponseInterface|null
Return values
ResponseInterface|null

decodeThreadId()

public decodeThreadId(string $threadId) : mixed
Parameters
$threadId : string

deleteMessage()

public deleteMessage(string $threadId, string $messageId) : void
Parameters
$threadId : string
$messageId : string

encodeThreadId()

public encodeThreadId(mixed $platformData) : string
Parameters
$platformData : mixed
Return values
string

getBotUserId()

public getBotUserId() : string|null
Return values
string|null

openDM()

public openDM(string $userId) : string|null
Parameters
$userId : string
Return values
string|null

parseWebhook()

public parseWebhook(ServerRequestInterface $request) : Message
Parameters
$request : ServerRequestInterface
Return values
Message

removeReaction()

public removeReaction(string $threadId, string $messageId, string $emoji) : void
Parameters
$threadId : string
$messageId : string
$emoji : string

startTyping()

public startTyping(string $threadId) : void
Parameters
$threadId : string

stream()

public stream(string $threadId, iterable<string|int, mixed> $textStream[, array<string|int, mixed> $options = [] ]) : SentMessage|null
Parameters
$threadId : string
$textStream : iterable<string|int, mixed>
$options : array<string|int, mixed> = []
Return values
SentMessage|null

verifyWebhook()

public verifyWebhook(ServerRequestInterface $request) : ResponseInterface|null
Parameters
$request : ServerRequestInterface
Return values
ResponseInterface|null

apiCall()

protected apiCall(string $method, string|null $path[, array<string|int, mixed> $params = [] ][, string|null $overrideUrl = null ][, bool $returnStream = false ]) : array<string|int, mixed>
Parameters
$method : string
$path : string|null
$params : array<string|int, mixed> = []
$overrideUrl : string|null = null
$returnStream : bool = false
Return values
array<string|int, mixed>

attachmentType()

protected attachmentType(string|null $contentType) : string
Parameters
$contentType : string|null
Return values
string

parseDate()

protected parseDate(string|null $value) : DateTimeImmutable
Parameters
$value : string|null
Return values
DateTimeImmutable

parseResource()

protected parseResource(array<string|int, mixed> $raw, array<string|int, mixed> $fallbackThread) : Message
Parameters
$raw : array<string|int, mixed>
$fallbackThread : array<string|int, mixed>
Return values
Message

senderFields()

protected senderFields(string $sender) : array<string|int, mixed>
Parameters
$sender : string
Return values
array<string|int, mixed>

threadIdForResource()

protected threadIdForResource(array<string|int, mixed> $raw, array<string|int, mixed> $fallback) : string
Parameters
$raw : array<string|int, mixed>
$fallback : array<string|int, mixed>
Return values
string

compareMessageDates()

private compareMessageDates(array<string|int, mixed> $a, array<string|int, mixed> $b) : int
Parameters
$a : array<string|int, mixed>
$b : array<string|int, mixed>
Return values
int
On this page

Search results