putKeyword method

Future<PutKeywordResult> putKeyword({
  1. required String keyword,
  2. required String keywordMessage,
  3. required String originationIdentity,
  4. KeywordAction? keywordAction,
})

Creates or updates a keyword configuration on an origination phone number or pool.

A keyword is a word that you can search for on a particular phone number or pool. It is also a specific word or phrase that an end user can send to your number to elicit a response, such as an informational message or a special offer. When your number receives a message that begins with a keyword, End User Messaging SMS responds with a customizable message.

If you specify a keyword that isn't valid, an error is returned.

May throw AccessDeniedException. May throw ConflictException. May throw InternalServerException. May throw ResourceNotFoundException. May throw ServiceQuotaExceededException. May throw ThrottlingException. May throw ValidationException.

Parameter keyword : The new keyword to add.

Parameter keywordMessage : The message associated with the keyword.

Parameter originationIdentity : The origination identity to use such as a PhoneNumberId, PhoneNumberArn, SenderId or SenderIdArn. You can use DescribePhoneNumbers get the values for PhoneNumberId and PhoneNumberArn while DescribeSenderIds can be used to get the values for SenderId and SenderIdArn.

Parameter keywordAction : The action to perform for the new keyword when it is received.

  • AUTOMATIC_RESPONSE: A message is sent to the recipient.
  • OPT_OUT: Keeps the recipient from receiving future messages.
  • OPT_IN: The recipient wants to receive future messages.

Implementation

Future<PutKeywordResult> putKeyword({
  required String keyword,
  required String keywordMessage,
  required String originationIdentity,
  KeywordAction? keywordAction,
}) async {
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.0',
    'X-Amz-Target': 'PinpointSMSVoiceV2.PutKeyword'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'Keyword': keyword,
      'KeywordMessage': keywordMessage,
      'OriginationIdentity': originationIdentity,
      if (keywordAction != null) 'KeywordAction': keywordAction.value,
    },
  );

  return PutKeywordResult.fromJson(jsonResponse.body);
}