How can i add a new custom header into Instant Message


#1

i have my dialplan from IM like this

[astsms]
exten => _.,1,NoOp(SMS receiving dialplan invoked)
exten => _.,n,NoOp(EXTENSION: ${EXTEN})
exten => _.,n,NoOp(STATE: ${EXTENSION_STATE(PJSIP/${EXTEN})})
exten => _.,n,NoOp(To ${MESSAGE(to)})
exten => _.,n,NoOp(From ${MESSAGE(from)})
exten => _.,n,NoOp(Body ${MESSAGE(body)})
exten => _.,n,Set(TMP=${CUT(MESSAGE(to),<,2)})
exten => _.,n,NoOp(TMP IS: ${TMP})
exten => _.,n,Set(TMP2=${CUT(TMP,@,1)})
exten => _.,n,Set(ACTUALTO=pjsip:${EXTEN})
exten => _.,n,Set(PJSIP_HEADER(add,X-IM-received)=${EPOCH})
exten => _.,n,MessageSend(${ACTUALTO},${MESSAGE(from)})
exten => _.,n,NoOp(Send status is ${MESSAGE_SEND_STATUS})
exten => _.,n,GotoIf($[“${MESSAGE_SEND_STATUS}” != “SUCCESS”]?sendfailedmsg)
exten => _.,n,Hangup()

exten =>_.,n(sendfailedmsg),Set(MESSAGE(body)="[${STRFTIME(${EPOCH},%d%m%Y-%H:%M:%S)}] message to ${EXTEN} has failed")
exten => _.,n,Set(ME_1=${CUT(MESSAGE(from),< ,2)})
exten => _.,n,Set(ACTUALFROM=${CUT(ME_1,@,1)})
exten => _.,n,MessageSend(${ACTUALFROM},ServiceCenter)
exten => _.,n,Hangup()
exten => _.,n,Hangup()

i have this error into asterisk cli:

res_pjsip_header_funcs.c:520 func_write_header: This function requires a PJSIP channel.

this happens when it executes: exten => _.,n,Set(PJSIP_HEADER(add,X-IM-received)=${EPOCH})

how can i add a new header correctly please?


#2

resolved by replacing

exten => _.,n,Set(PJSIP_HEADER(add,X-IM-received)=${EPOCH})

by

exten => _.,n,Set(MESSAGE_DATA(X-IM-received)=${EPOCH})